<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>时间</title>
		<script> 
		var timer;
		 function showTime(){
			 var d=new Date();
			 document.getElementById("d1").innerHTML=d.toLocaleTimeString();
		 }
		 window.onload=function(){
			 showTime();
		 	 timer=window.setInterval("showTime()",1000);
		 }
		 function stopTimer(){
			 window.clearInterval(timer);
		 }
		</script>
	</head>
	<body>
		<div id="d1">
			
		</div>
		<button type="button" onclick="stopTimer()">停止</button>
	</body>
</html>
